package com.initialize.common.tool.util;

import java.util.Calendar;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: jane
 * Date: 2019/12/27
 * Time: 1:12 下午
 * Description:
 */
public class DateTool {
    /**
     * 获取当前时间 生成数据库需要的格式
     * @return
     */
    public static Date createData() {
        Date date = new Date();
        return date;
    }


    /**
     * 比较时间,返回单位(秒)
     * @param timestamp 需要比较的时间
     * @return
     */
    public static long doTimeStampNew(String timestamp) {
        long time = Long.parseLong(timestamp);
        long l = System.currentTimeMillis();
        return (l - time) / 1000;
    }

    /**
     * 计算多少天以后的日期
     * @param day
     * @return
     */
    public static Date theDateAfterTheCalculation(int day) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.DATE, day);
        return calendar.getTime();

    }
}